package com.chinairi.mall.util;

import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author gsl
 * @date 2020-11-30 18:11
 */
public class NumberFormatUtil {
    /**
     * 根据规则生成流水号
     *
     * @param numberDigit 流水号的位数
     * @param numberValue 流水号的值
     * @return 流水号的值的字符串信息
     */
    public static String numberFormat(int numberDigit, int numberValue) {
        NumberFormat formatter = NumberFormat.getNumberInstance();
        formatter.setMinimumIntegerDigits(numberDigit);
        formatter.setGroupingUsed(false);
        //日期前缀
        SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
        String dateString = date.format(new Date()).replace("-", "");
        return dateString + formatter.format(numberValue);
    }


}
